home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / asm32.zip / E32.ZIP / GOTO.ASM < prev    next >
Assembly Source File  |  1996-02-22  |  3KB  |  200 lines

  1. ; GOTO.ASM for E32 - Copyright (C) 1994 Douglas Herr
  2. ;  all rights reserved
  3.  
  4. include    model.inc
  5.  
  6. public    goto
  7. extrn    dwordtohex:near, hextodword:near
  8. extrn    tprint:near, tprintce:near
  9. extrn    getkey:near
  10. extrn    ucursoron:near, locate:near
  11. extrn    i4tostr:near, strtoi4:near
  12. extrn    isdigit:near
  13. extrn    up:near, down:near
  14.  
  15. include    dataseg.inc
  16. extrn    rows:byte, inverse:byte
  17. extrn    cursor:dword
  18. extrn    display_mode:byte
  19. extrn    first_row:byte
  20. extrn    file_row:dword
  21. goto_msg    db ' Go to: ',0
  22. goto_msg_len    equ    $-goto_msg-1
  23. row_msg        db ' row ',0
  24. row_msg_len    equ    $-row_msg-1
  25. @curseg    ends
  26.  
  27. string_limit    equ    byte ptr [ebp-1]
  28.  
  29. include    codeseg.inc
  30. goto:
  31.     mov    dh,rows
  32.     inc    dh
  33.     xor    dl,dl
  34.     mov    ah,inverse
  35.     lea    esi,goto_msg
  36.     call    tprintce
  37.     mov    dl,goto_msg_len
  38.  
  39.     cmp    display_mode,4
  40.     je    _hex
  41.  
  42. ; ASCII display mode
  43.  
  44. asciistring    equ    [ebp-13]
  45.  
  46.     enter    13,0
  47.     mov    string_limit,11
  48.     lea    esi,row_msg
  49.     call    tprint
  50.  
  51. _ascii_row:
  52.     mov    eax,file_row
  53.     lea    esi,asciistring
  54.     call    i4tostr
  55.     movzx    ebx,string_limit
  56.     dec    ebx
  57.  
  58. _next_row:
  59.     lea    esi,asciistring
  60.     mov    dl,row_msg_len+goto_msg_len
  61.     mov    ah,inverse
  62.     call    tprint
  63.     push    edx
  64.     add    dl,bl
  65.     call    ucursoron
  66.     pop    edx
  67.     call    getkey
  68.     shr    ah,1
  69.     jnc    _ascii0
  70.     call    _extended
  71.     jmp    _next_row
  72.  
  73. _ascii0:
  74.     cmp    al,27            ; ESC?
  75.     je    short _ascii_exit
  76.     cmp    al,0Dh            ; Enter?
  77.     je    short _ascii_enter
  78.     cmp    al,' '
  79.     je    short _ascii1
  80.     call    isdigit
  81.     jc    _next_row
  82.  
  83. _ascii1:
  84.     mov    [esi+ebx],al    ; add key to string
  85.     call    _right        ; move cursor right
  86.     jmp    _next_row    ; get next key
  87.  
  88. _ascii_enter:
  89.     call    strtoi4
  90.     mov    ebx,offset @curseg:down
  91.     sub    eax,file_row
  92.     jnc    short _ascii3
  93.     mov    ebx,offset @curseg:up
  94.     neg    eax
  95. _ascii3:
  96.     mov    ecx,eax
  97.     push    ebp
  98. _ascii4:
  99.     push    ecx
  100.     push    ebx
  101.     call    ebx
  102.     pop    ebx
  103.     pop    ecx
  104.     loop    _ascii4
  105.     pop    ebp
  106.  
  107. _ascii_exit:
  108.     leave
  109.     clc
  110.     ret
  111.  
  112. hexstring    equ    [ebp-11]
  113.  
  114. _hex:
  115.     enter    11,0
  116.     mov    string_limit,8
  117.     mov    eax,cursor
  118.     lea    esi,hexstring
  119.     call    dwordtohex
  120.     mov    ah,inverse
  121.     xor    ebx,ebx
  122.  
  123. _hex_getkey:
  124.     mov    ah,inverse
  125.     lea    esi,hexstring
  126.     call    tprintce
  127.     push    edx
  128.     add    dl,bl
  129.     call    ucursoron
  130.     pop    edx
  131.     call    getkey
  132.     shr    ah,1        ; extended keycode?
  133.     jnc    _hex0
  134.     call    _extended
  135.     jmp    _hex_getkey
  136.  
  137. _hex0:
  138.     cmp    al,27        ; ESC?
  139.     je    short _hex_exit
  140.     cmp    al,0Dh
  141.     je    short _hex_enter
  142.  
  143.     cmp    al,'0'
  144.     jb    _hex_getkey
  145.     cmp    al,'9'
  146.     jbe    short _hex_addkey
  147.     and    al,(0FFh-32)    ; upper case
  148.     cmp    al,'A'
  149.     jb    _hex_getkey
  150.     cmp    al,'F'
  151.     ja    _hex_getkey
  152.  
  153. _hex_addkey:
  154.     mov    [esi+ebx],al
  155.     call    _right
  156.     jmp    _hex_getkey
  157.  
  158.  
  159. _hex_enter:
  160.     call    hextodword
  161.     mov    esi,eax
  162.     mov    cursor,esi
  163.     mov    dh,rows
  164.     sub    dh,first_row
  165.     shr    dh,1
  166.     add    dh,first_row
  167.     call    locate
  168.  
  169. _hex_exit:
  170.     leave
  171.     ret
  172.  
  173. _extended:
  174.     cmp    al,4Dh
  175.     jne    short _ex0
  176.     call    _right
  177.     ret
  178. _ex0:
  179.     cmp    al,4Bh
  180.     jne    _hex_getkey
  181.     call    _left
  182.     ret
  183.  
  184.  
  185. _left:
  186.     sub    ebx,1
  187.     adc    ebx,0
  188.     ret
  189.  
  190. _right:
  191.     inc    ebx
  192.     cmp    bl,string_limit
  193.     cmc
  194.     sbb    ebx,0
  195.     ret
  196.  
  197.  
  198. @curseg    ends
  199.     end
  200.